﻿
Partial Class goods
    Inherits System.Web.UI.Page
    Dim tbCode, xbCode, GoodsName, ItemViewsUrl, EXLEVEL, CID, GoodsPrice, GoodsSaller, GoodsSallerShopId, GoodsPic, GoodsItemDescIUrl, GoodsId
    Dim ShopBanner, ThirtydDaySale, ShopAddress, ViewCountUrl, ShopEvaluation, AttributesList, GoodsInfo, ReviewsUrl, GoodsInfoUrl, ShopExlevelPic, ShopUserId
    Dim CArray(40, 13)
    Public GoodsTitle, CurCat_RootCatName, CurCat_RootCatId, CurCat_Name, CurCat_Id
    Function getdj()
        Dim shopdengjipic
        shopdengjipic = ""
        If ShopExlevelPic <> "" Then
            getdj = ShopExlevelPic
            Exit Function
        End If
        If EXLEVEL = "" Or EXLEVEL = "0" Then
            shopdengjipic = "http://pics.taobaocdn.com/newrank/" & getText(tbCode, "http://pics.taobaocdn.com/newrank/", """  ")
            getdj = shopdengjipic
            'Exit Function
        End If

        If EXLEVEL = 0 Then
            'shopdengjiB = "商城"
            shopdengjipic = "images/store.gif"
        End If
        If EXLEVEL = 1 Then
            'shopdengjiB = "一星"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_red_1.gif"
        End If
        If EXLEVEL = 2 Then
            'shopdengjiB = "双星"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_red_2.gif"
        End If
        If EXLEVEL = 3 Then
            'shopdengjiB = "三星"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_red_3.gif"
        End If
        If EXLEVEL = 4 Then
            'shopdengjiB = "四星"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_red_4.gif"
        End If
        If EXLEVEL = 5 Then
            'shopdengjiB = "五星"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_red_5.gif"
        End If
        If EXLEVEL = 6 Then
            'shopdengjiB = "一钻"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_blue_1.gif"
        End If
        If EXLEVEL = 7 Then
            'shopdengjiB = "双钻"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_blue_2.gif"
        End If
        If EXLEVEL = 8 Then
            'shopdengjiB = "三钻"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_blue_3.gif"
        End If
        If EXLEVEL = 9 Then
            'shopdengjiB = "四钻"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_blue_4.gif"
        End If
        If EXLEVEL = 10 Then
            'shopdengjiB = "五钻"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_blue_5.gif"
        End If
        If EXLEVEL = 11 Then
            'shopdengjiB = "一皇冠"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_cap_1.gif"
        End If
        If EXLEVEL = 12 Then
            ' shopdengjiB = "双皇冠"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_cap_2.gif"
        End If
        If EXLEVEL = 13 Then
            ' shopdengjiB = "三皇冠"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_cap_3.gif"
        End If
        If EXLEVEL = 14 Then
            'shopdengjiB = "四皇冠"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_cap_4.gif"
        End If
        If EXLEVEL = 15 Then
            'shopdengjiB = "五皇冠"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_cap_5.gif"
        End If
        If EXLEVEL = 16 Then
            'shopdengjiB = "一金冠"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_crown_1.gif"
        End If
        If EXLEVEL = 17 Then
            'shopdengjiB = "双金冠"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_crown_2.gif"
        End If
        If EXLEVEL = 18 Then
            'shopdengjiB = "三金冠"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_crown_3.gif"
        End If
        If EXLEVEL = 19 Then
            'shopdengjiB = "四金冠"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_crown_4.gif"
        End If
        If EXLEVEL = 20 Then
            ' shopdengjiB = "五金冠"
            shopdengjipic = "http://pics.taobaocdn.com/newrank/s_crown_5.gif"
        End If
        getdj = shopdengjipic
    End Function

    Function Pic2Seller_Credit()
        Dim picstr
        picstr = getText(tbCode, "http://pics.taobaocdn.com/newrank/", """  ")
        If picstr = "s_red_1.gif" Then
            Pic2Seller_Credit = "一星"
        End If
        If picstr = "s_red_2.gif" Then
            Pic2Seller_Credit = "双星"
        End If
        If picstr = "s_red_3.gif" Then
            Pic2Seller_Credit = "三星"
        End If
        If picstr = "s_red_4.gif" Then
            Pic2Seller_Credit = "四星"
        End If
        If picstr = "s_red_5.gif" Then
            Pic2Seller_Credit = "五星"
        End If
        If picstr = "s_blue_1.gif" Then
            Pic2Seller_Credit = "一钻"
        End If
        If picstr = "s_blue_2.gif" Then
            Pic2Seller_Credit = "双钻"
        End If
        If picstr = "s_blue_3.gif" Then
            Pic2Seller_Credit = "三钻"
        End If
        If picstr = "s_blue_4.gif" Then
            Pic2Seller_Credit = "四钻"
        End If
        If picstr = "s_blue_5.gif" Then
            Pic2Seller_Credit = "五钻"
        End If
        If picstr = "s_cap_1.gif" Then
            Pic2Seller_Credit = "一皇冠"
        End If
        If picstr = "s_cap_2.gif" Then
            Pic2Seller_Credit = "双皇冠"
        End If
        If picstr = "s_cap_3.gif" Then
            Pic2Seller_Credit = "三皇冠"
        End If
        If picstr = "s_cap_4.gif" Then
            Pic2Seller_Credit = "四皇冠"
        End If
        If picstr = "s_cap_5.gif" Then
            Pic2Seller_Credit = "五皇冠"
        End If
        If picstr = "s_crown_1.gif" Then
            Pic2Seller_Credit = "一金冠"
        End If
        If picstr = "s_crown_2.gif" Then
            Pic2Seller_Credit = "双金冠"
        End If
        If picstr = "s_crown_3.gif" Then
            Pic2Seller_Credit = "三金冠"
        End If
        If picstr = "s_crown_4.gif" Then
            Pic2Seller_Credit = "四金冠"
        End If
        If picstr = "s_crown_5.gif" Then
            Pic2Seller_Credit = "五金冠"
        End If
        If Pic2Seller_Credit <> "" Then Exit Function
        If InStr(tbCode, "淘宝商城，品质保证") Then
            Pic2Seller_Credit = "商城"
        End If
        Pic2Seller_Credit = picstr
    End Function

    Function getText(ByVal tmp, ByVal s, ByVal e)
        On Error Resume Next
        Dim String1, String2, arrstr, j
        String1 = s
        String2 = e
        Dim fbegin
        Dim fend
        fbegin = 1
        fend = 1
        Do
            fbegin = InStr(fbegin, tmp, String1)
            If fbegin = 0 Then Exit Function
            fend = InStr(fbegin, tmp, String2)
            arrstr = Mid(tmp, fbegin + Len(String1), fend - (fbegin + Len(String1)))
            getText = arrstr
            Exit Do
            fbegin = fend + Len(String2)
        Loop While True
    End Function
    Function getTextA(ByVal tmp, ByVal s, ByVal e)
        On Error Resume Next
        Dim String1, String2, arrstr, j
        String1 = s
        String2 = e
        Dim fbegin
        Dim fend
        fbegin = 1
        fend = 1
        getTextA = ""
        j = 0
        Do
            fbegin = InStr(fbegin, tmp, String1)
            If fbegin = 0 Then Exit Function
            fend = InStr(fbegin, tmp, String2)
            arrstr = Mid(tmp, fbegin + Len(String1), fend - (fbegin + Len(String1)))
            getTextA = getTextA & arrstr & "@,@,@"
            j = j + 1
            If j > 4 Then Exit Do
            fbegin = fend + Len(String2)
        Loop While True
    End Function
    Function gethtml(ByVal tmp, ByVal s, ByVal e, ByVal id)
        On Error Resume Next
        Dim String1, String2, arrstr, j
        String1 = s
        String2 = e
        Dim fbegin
        Dim fend
        fbegin = 1
        fend = 1
        j = 0
        Do
            fbegin = InStr(fbegin, tmp, String1)
            If fbegin = 0 Then Exit Function
            fend = InStr(fbegin, tmp, String2)
            arrstr = Mid(tmp, fbegin + Len(String1), fend - (fbegin + Len(String1)))
            If id <> -1 Then
                CArray(j, id) = arrstr
                j = j + 1
            End If
            gethtml = arrstr
            If id = -1 Then Exit Function
            fbegin = fend + Len(String2)
        Loop While True
    End Function
    Function getstr(ByVal iRemote)
        On Error Resume Next
        Dim xPost, sGet
        iRemote = iRemote
        xPost = Server.CreateObject("msxml2.serverxmlhttp") 'msxml2.serverxmlhttp
        xPost.Open("GET", iRemote, False)
        xPost.setrequestheader("referer", "http://taoke.alimama.com/spreader/search_auction.htm")
        xPost.Send()
        sGet = CreateObject("ADODB.Stream")
        sGet.Mode = 3
        sGet.Type = 1
        sGet.Open()
        sGet.Write(xPost.responseBody)
        sGet.Position = 0
        sGet.Type = 2
        sGet.Charset = "gb2312" ' "gb2312"
        getstr = sGet.ReadText

    End Function
    Function GetShopBanner() '得到商品BANNER
        'tbCode = getstr(url)
        If ShopBanner <> "" Then GetShopBanner = ShopBanner : Exit Function
        If InStr(tbCode, "<div class=""box shop-header "" style=""") Then
            GetShopBanner = getText(tbCode, "<div class=""box shop-header "" style="" background-image: url(", "); height:150px;"">")
            If GetShopBanner <> "" Then
                GetShopBanner = "<div class=""body-head"" style="" background-image: url(" & GetShopBanner & "); height:150px;"">"
            End If
        End If
        If InStr(tbCode, "<div class=""box shop-header  flash-banner"" style=""") Then
            GetShopBanner = getText(tbCode, "<embed height=""150"" width=""950"" type=""application/x-shockwave-flash"" src=""", """ quality=""high""")
            If GetShopBanner <> "" Then
                GetShopBanner = "<div class=""body-head""><embed height=""150"" width=""950"" type=""application/x-shockwave-flash"" src=""" & GetShopBanner & """ quality=""high"" allowscriptaccess=""always"" wmode=""transparent""/>"
            End If
        End If
        If GetShopBanner <> "" Then GetShopBanner = GetShopBanner & vbNewLine & Space(5) & "<div class=""body-skin"">" & vbNewLine & Space(10) & "<h2>" & GoodsName & "</h2>"
        ShopBanner = GetShopBanner
    End Function
    Function GetThirtydDaySale() '得到商品30天销售数量
        If ThirtydDaySale <> "" Then GetThirtydDaySale = ThirtydDaySale : Exit Function
        If InStr(tbCode, "30天售出") Then
            GetThirtydDaySale = getText(tbCode, "30天售出", "</li>")
        Else
            If InStr(tbCode, "<span>已 售 出") Then
                GetThirtydDaySale = getText(tbCode, "<span>已 售 出", "</li>")
            End If
        End If

        If GetThirtydDaySale <> "" Then
            GetThirtydDaySale = getText(GetThirtydDaySale, "<em>", "</em>")
            ThirtydDaySale = GetThirtydDaySale
        End If
        'GetShopBanner = getText(tbCode)
    End Function
    Function GetShopAddress() '得到商品30天销售数量
        If ShopAddress <> "" Then GetShopAddress = ShopAddress : Exit Function
        If InStr(tbCode, "所在地区：</span>") Then
            GetShopAddress = getText(tbCode, "所在地区：</span>", "</li>")
        Else
            If InStr(tbCode, "<label>所 在 地：</label>") Then
                GetShopAddress = getText(tbCode, "<label>所 在 地：</label>", "</li>")
                GetShopAddress = Replace(GetShopAddress, vbNewLine, "")
                GetShopAddress = Replace(GetShopAddress, vbTab, "")
                If InStr(GetShopAddress, ",") Then
                    GetShopAddress = Right(GetShopAddress, Len(GetShopAddress) - InStrRev(GetShopAddress, ","))
                End If
            End If
        End If


        GetShopAddress = Trim(GetShopAddress)
        ShopAddress = GetShopAddress
    End Function
    Function GetViewCountUrl() '得到商品浏览数目
        If ViewCountUrl <> "" Then GetViewCountUrl = ViewCountUrl : Exit Function
        If ItemViewsUrl = "" Then
            GetViewCountUrl = getText(tbCode, "apiItemViews"": """, """,")
            ItemViewsUrl = GetViewCountUrl
        End If
        GetViewCountUrl = Trim(ItemViewsUrl)
        ViewCountUrl = GetViewCountUrl
    End Function
    Function GetShopEvaluation() '得到店铺好评率
        If ShopEvaluation <> "" Then GetShopEvaluation = ShopEvaluation : Exit Function
        If InStr(tbCode, "</a><em>(好评率:") > 0 Then GetShopEvaluation = getText(tbCode, "</a><em>(好评率:", "%)</em>")
        If InStr(tbCode, "<span>好评率：</span>") > 0 Then GetShopEvaluation = getText(tbCode, "<span>好评率：</span>", "</li>")
        If InStr(tbCode, "<h4>淘宝商城</h4>") > 0 Then GetShopEvaluation = "100"
        If InStr(GetShopEvaluation, "%") = 0 Then GetShopEvaluation = GetShopEvaluation & "%"
        GetShopEvaluation = Trim(GetShopEvaluation)
        ShopEvaluation = GetShopEvaluation
    End Function

    Function GetAttributesList() '得到商品属性
        If AttributesList <> "" Then GetAttributesList = AttributesList : Exit Function
        If InStr(tbCode, "<ul class=""attributes-list"">") > 0 Then GetAttributesList = getText(tbCode, "<ul class=""attributes-list"">", "</div>")
        GetAttributesList = Replace(GetAttributesList, vbTab, "")
        GetAttributesList = Replace(GetAttributesList, vbNewLine, "")
        GetAttributesList = Trim(GetAttributesList)
        AttributesList = GetAttributesList
    End Function
    Function GetShopUserId() '得到商品属性
        
        If ShopUserId <> "" And ShopUserId <> "0" Then GetShopUserId = ShopUserId : Exit Function
     
        If InStr(tbCode, "key: user-") > 0 Then GetShopUserId = getText(tbCode, "key: user-", "-prototype")
        GetShopUserId = Trim(GetShopUserId)
        ShopUserId = GetShopUserId

    End Function
    'GoodsInfoUrl

    Function GetGoodsInfo() '得到商品详细信息
        On Error Resume Next
        If GoodsInfo <> "" Then GetGoodsInfo = GoodsInfo : Exit Function
        Dim USER_AGENT
        USER_AGENT = LCase(Request.ServerVariables("HTTP_USER_AGENT"))
        'If InStr(USER_AGENT, "baidu") Or InStr(USER_AGENT, "bot") Then Exit Function
        Dim objFso, path, filename, ts, txt, line
        objFso = Server.CreateObject("Scripting.FileSystemObject")
        path = "CaChe/"
        filename = path & CID & ".tddcache"
        If Not objFso.FileExists(Server.MapPath(filename)) Then
            GetGoodsInfo = GetGoodsInfoUrl() 'getText(tbCode, "apiItemDesc"":""", """,")
            If InStr(GetGoodsInfo, "var desc='") > 0 Then
                GetGoodsInfo = getText(tbCode, "apiItemDesc"":""", """,")
            End If

            GetGoodsInfo = getstr(GetGoodsInfo)
            GetGoodsInfo = Replace(GetGoodsInfo, "var desc='", "")
            GetGoodsInfo = Replace(GetGoodsInfo, "';", "")
            GetGoodsInfo = Replace(GetGoodsInfo, ">\", ">")
            GetGoodsInfo = Replace(GetGoodsInfo, "> \", ">")
            GetGoodsInfo = Replace(GetGoodsInfo, "\", "")
            GoodsInfo = GetGoodsInfo

            If InStr(USER_AGENT, "baidu") = 0 And InStr(USER_AGENT, "bot") = 0 And Left(Request.QueryString("id"), 6) <> "168861" Then


                If (objFso.FolderExists(Server.MapPath(path))) Then '判断文件夹是否存在
                Else
                    objFso.CreateFolder(Server.MapPath(path))
                End If
                ts = objFso.createtextfile(Server.MapPath(filename), True)
                ts.write(GoodsInfo)
                ts.close()
                objFso = Nothing
            End If
        Else
            If objFso.FileExists(Server.MapPath(filename)) Then
                txt = objFso.opentextfile(Server.MapPath(filename), 1, True)
                If Not txt.atendofstream Then
                    line = txt.ReadAll
                    If line <> vbNewLine Then
                        GetGoodsInfo = GetGoodsInfo & line
                    End If
                End If
                txt.close()
                GoodsInfo = GetGoodsInfo
            End If
        End If
    End Function
    Function GetGoodsInfoUrl() '得到商品详细信息
        If GoodsInfoUrl <> "" Then GetGoodsInfoUrl = GoodsInfoUrl : Exit Function
        If InStr(tbCode, "apiItemDesc"":""") Then
            GetGoodsInfoUrl = getText(tbCode, "apiItemDesc"":""", """,")
            Exit Function
        End If

        If InStr(tbCode, "})('") Then
            GetGoodsInfoUrl = getText(tbCode, "})('", "');")
            Exit Function
        End If
    End Function
    'ReviewsUrl
    Function GetReviewsUrl() '得到商品评价地址
        If ReviewsUrl <> "" Then GetReviewsUrl = ReviewsUrl : Exit Function
        GetReviewsUrl = "http://rate.taobao.com/baby-rate-" & getText(tbCode, "userId:       '", "',")
        GetReviewsUrl = GetReviewsUrl & "--auctionNumId|" & getText(tbCode, "item_id_num"" value=""", """ />") & "--ismore|1--showContent|1--currentPage|1.htm"
        ReviewsUrl = GetReviewsUrl
        'Response.Write(GetReviewsUrl)
        'Response.End()
    End Function
    Function GetGoodsXbCode() '得到商品评价地址
        If xbCode <> "" Then GetGoodsXbCode = xbCode : Exit Function
        If InStr(tbCode, "<span class=""service-xb24"">") Then
            GetGoodsXbCode = getText(tbCode, "<span class=""service-xb24"">", "</dl>")
            xbCode = GetGoodsXbCode
        Else
            xbCode = ""
        End If
    End Function

    Function GetGoodsName() '得到商品名称
        If GoodsName <> "" Then GetGoodsName = GoodsName : Exit Function
        If InStr(tbCode, "hidden"" name=""title"" value=""") Then
            GetGoodsName = getText(tbCode, "hidden"" name=""title"" value=""", """ />")
            GoodsName = GetGoodsName
        Else
            GoodsName = ""
        End If
    End Function
    Function GetGoodsPrice() '得到商品价格
        If GoodsPrice <> "" Then GetGoodsPrice = GoodsPrice : Exit Function
        If InStr(tbCode, "current_price"" value= """) Then
            GetGoodsPrice = getText(tbCode, "current_price"" value= """, """ />")
            GoodsPrice = GetGoodsPrice
        Else
            GoodsPrice = ""
        End If
    End Function
    Function GetGoodsSaller() '得到商品卖家
        If GoodsSaller <> "" Then GetGoodsSaller = GoodsSaller : Exit Function
        If InStr(tbCode, "seller_nickname"" value=""") Then
            GetGoodsSaller = getText(tbCode, "seller_nickname"" value=""", """ />")
            GoodsSaller = GetGoodsSaller
        Else
            GoodsSaller = ""
        End If
    End Function
    Function GetGoodsPic() '得到商品图片
        If GoodsPic <> "" Then GetGoodsPic = GoodsPic : Exit Function

        If InStr(tbCode, "J_ImgBooth"" src=""") Then
            If InStr(tbCode, """  data-hasZoom=") Then
                GetGoodsPic = getText(tbCode, "J_ImgBooth"" src=""", """  data-hasZoom=")
            Else
                GetGoodsPic = getText(tbCode, "J_ImgBooth"" src=""", "_310x310.jpg")
            End If

            GetGoodsPic = Replace(GetGoodsPic, "_310x310.jpg", "")
            GoodsPic = GetGoodsPic
        Else
            GoodsPic = ""
        End If
    End Function
    Function GetGoodsItemDescIUrl() '得到商品图片
        If GoodsItemDescIUrl <> "" Then GetGoodsItemDescIUrl = GoodsItemDescIUrl : Exit Function

        If InStr(tbCode, "apiItemDesc"":""") Then

            GetGoodsItemDescIUrl = getText(tbCode, "apiItemDesc"":""", """,")
            GoodsItemDescIUrl = GetGoodsItemDescIUrl
        Else
            GoodsItemDescIUrl = ""
        End If
    End Function
    Function GetOtherGoods() '得到商品图片
        Dim shopId, othercode, GoodsIdArr, GoodsIdArr2, GoodsNameArr, GoodsNameArr2, GoodsPicArr, GoodsPriceArr, url
        url = ""
        If InStr(tbCode, "shopId"" value=""") Then
            shopId = getText(tbCode, "shopId"" value=""", """ />")
            url = "http://item.taobao.com/json/recommendedItem.htm?user_num_id=" & getText(tbCode, "userId:       '", "',") & "&shop_id=" & shopId
        Else
            If InStr(tbCode, "recommendedItem.htm?") Then
                url = "http://item.taobao.com/json/recommendedItem.htm" & getText(tbCode, "json/recommendedItem.htm", ",J_recommendation")
            End If
        End If
        If url <> "" Then
            othercode = getstr(url)
            GoodsIdArr = getTextA(othercode, "permalink"" href=""http://item.taobao.com/item.htm?id=", """ target=")
            GoodsNameArr = getTextA(othercode, "<div class=""desc"">", "</a>")
            GoodsPicArr = getTextA(othercode, "<img src=""", """ alt=")
            GoodsPicArr = Replace(GoodsPicArr, "_sum.jpg", "")
            GoodsPriceArr = getTextA(othercode, "<strong>", "元</strong>")
            Dim i
            If InStr(GoodsNameArr, """>") Then
                GoodsNameArr2 = Split(GoodsNameArr, "@,@,@")
                GoodsNameArr = ""
                For i = 0 To UBound(GoodsNameArr2)
                    If GoodsNameArr2(i) <> "" Then
                        GoodsNameArr = GoodsNameArr & Right(GoodsNameArr2(i), Len(GoodsNameArr2(i)) - InStrRev(GoodsNameArr2(i), """>") - 1) & "@,@,@"
                    End If
                Next
            End If
            GoodsIdArr2 = Split(GoodsIdArr, "@,@,@")
            GoodsIdArr = ""
            For i = 0 To UBound(GoodsIdArr2)
                If GoodsIdArr2(i) <> "" Then
                    GoodsIdArr = GoodsIdArr & "168861" & GoodsIdArr2(i) & "@,@,@"
                End If
            Next
            GetOtherGoods = GoodsIdArr & "|split|" & vbNewLine & GoodsNameArr & "|split|" & vbNewLine & GoodsPicArr & "|split|" & vbNewLine & GoodsPriceArr
        Else
            GoodsPic = ""
        End If
    End Function
    Function GetGoodsSallerShopId() '得到商品卖家
        If GoodsSallerShopId <> "" Then GetGoodsSallerShopId = GoodsSallerShopId : Exit Function
        If InStr(tbCode, "userId:       '") Then
            GetGoodsSallerShopId = getText(tbCode, "userId:       '", "',")

            If IsNumeric(GetGoodsSallerShopId) Then
                GetGoodsSallerShopId = Int(GetGoodsSallerShopId)

            End If
            GoodsSallerShopId = GetGoodsSallerShopId
        Else
            GoodsSallerShopId = ""
        End If
    End Function


    Function LoadFile(ByVal File)
        Dim objStream
        On Error Resume Next
        objStream = Server.CreateObject("ADODB.Stream")
        If Err.Number = -2147221005 Then
            LoadFile = ""
            Exit Function
        End If
        With objStream
            .Type = 2
            .Mode = 3
            .Open()
            .LoadFromFile(Server.MapPath(File))
            If Err.Number <> 0 Then
                LoadFile = ""
                Exit Function
            End If
            .Charset = "GB2312"
            .Position = 2
            LoadFile = .ReadText
            .Close()
        End With
        objStream = Nothing
    End Function
    Function GetSize(ByVal filename)
        Dim fso, filepath, file, b, f, fsize, f_size
        fso = server.createobject("scripting.filesystemobject")
        filepath = server.mappath(filename)
        f = fso.getfile(filepath)
        fsize = f.size
        GetSize = fsize
        Exit Function
        If fsize > 1048576 Then
            f_size = left((fsize / 1024) / 1024, 4) & "MB"
        ElseIf fsize > 1024 Then
            f_size = left(fsize / 1024, 4) & "KB"
        Else
            f_size = fsize
        End If
        GetSize = fsize
    End Function
    Function WeiYuanChuang(ByVal word)
        WeiYuanChuang = word
        Exit Function
        Dim WeiCode, WeiCodeArr, i, arr, WordStr
        WeiCode = ""
        If Application("WeiYuanChuangFileTxt") <> "" Then
            If Application("WeiYuanChuangFileSize") = GetSize("tyc.ini") Then
                WeiCode = Application("WeiYuanChuangFileTxt")
            Else
                WeiCode = LoadFile("tyc.ini")
                Application("WeiYuanChuangFileTxt") = WeiCode
                Application("WeiYuanChuangFileSize") = GetSize("tyc.ini")
            End If
        Else
            WeiCode = LoadFile("tyc.ini")
            Application("WeiYuanChuangFileTxt") = WeiCode
            Application("WeiYuanChuangFileSize") = GetSize("tyc.ini")
        End If
        If WeiCode = "" Then
            WeiYuanChuang = word
            Exit Function
        End If
        WeiCodeArr = Split(WeiCode, vbNewLine)
        For i = 0 To UBound(WeiCodeArr)
            If InStr(WeiCodeArr(i), ",") Then
                arr = Split(WeiCodeArr(i), ",")
                WordStr = arr(1)
                If InStr(word, WordStr) Then
                    WordStr = Left(WordStr, 1) & "{--}" & Right(WordStr, Len(WordStr) - 1)
                    word = Replace(word, arr(0), WordStr)
                End If


            End If
        Next
        'WordStr = 
        WeiYuanChuang = Replace(word, "{--}", "")
    End Function

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim c, connstr, conn, rs, rs1, GoodUrl

        GoodsId = Request.QueryString("id")
        connstr = ConfigurationSettings.AppSettings("SQLConnString") & """" & Server.MapPath(".") & "\" & ConfigurationSettings.AppSettings("dbPath") & """"
        conn = Server.CreateObject("ADODB.Connection")
        conn.open(connstr)
        rs = Server.CreateObject("adodb.recordset")
        If Left(GoodsId, 6) = "168861" Then
            GoodsId = Replace(GoodsId, "168861", "")
            CID = GoodsId
            GoodUrl = "http://item.taobao.com/auction/item_detail.htm?item_num_id=" & GoodsId
            tbCode = getstr(GoodUrl)
            If InStr(tbCode, "查看的宝贝不存在") > 0 Then
                'Response.Write("<h1>很抱歉，您查看的商品不存在，可能已下架或者被转移</h1>")
                Response.Redirect("404.html")

                Response.End()
            End If

        Else


            rs.open("select *  from commodity where id=" & Int(Request.QueryString("id")), conn, 1, 3)
            If Not rs.eof Then
                EXLEVEL = rs("EXLEVEL").value.ToString
                GoodsName = rs("Name").value
                ShopExlevelPic = rs("ShopExlevelPic").value.ToString
                ShopUserId = rs("ShopUserId").value.ToString
                CID = rs("CID").value
                ThirtydDaySale = rs("TaoBaoSale").value.ToString
                ShopAddress = rs("ShopAddress").value.ToString
                ViewCountUrl = rs("ItemViewsUrl").value.ToString
                ReviewsUrl = rs("ReviewsUrl").value.ToString
                ShopEvaluation = rs("ShopEvaluation").value.ToString
                AttributesList = rs("attributeslist").value.ToString
                GoodsInfoUrl = rs("ItemDescIUrl").value.ToString
                ShopBanner = rs("ShopBanner").value.ToString
                ShopAddress = rs("ShopAddress").value.ToString
                xbCode = rs("ShopXbCode").value.ToString
                If ThirtydDaySale = "" Or ViewCountUrl = "" Or ReviewsUrl = "" Or ShopEvaluation = "" Or AttributesList = "" Or GoodsInfoUrl = "" Or ShopBanner = "" Or (EXLEVEL = "" Or EXLEVEL = "0" And ShopExlevelPic = "") Or (ShopUserId = "0" Or ShopUserId = "") Then
                    tbCode = getstr(rs("Curl").value)
                    If InStr(tbCode, "item_id") = 0 Then
                        tbCode = getstr(rs("Curl").value)
                        If InStr(tbCode, "查看的宝贝不存在") > 0 Then
                            ' Response.Write("<h1>很抱歉，您查看的商品不存在，可能已下架或者被转移</h1>")

                            rs.close()
                            Response.Redirect("404.html")
                            Response.End()
                        End If
                    End If
                End If

            Else
                'Response.Write("<h1>该商品不存在</h1>")
                'rs.close()
                'Response.End()
            End If
            rs.close()
        End If

        CurCat_RootCatId = getText(tbCode, "rootCatId"" value=""", """ />")
        CurCat_Id = getText(tbCode, "height+'&category=item_", "&userid=")
        If IsNumeric(CurCat_Id) Then
            rs.open("select *  from catclass_api where cat_id=" & CurCat_Id, conn, 1, 3)
            If Not rs.eof Then
                CurCat_Name = rs("cat_name").value
            End If
            rs.close()
        End If
        Dim Title_Id
        Title_Id = 0
        GoodsTitle = ""
        If IsNumeric(CurCat_RootCatId) Then
            rs.open("select *  from catclass_api where cat_id=" & CurCat_RootCatId, conn, 1, 3)
            If Not rs.eof Then
                CurCat_RootCatName = rs("cat_name").value
                If Not IsDBNull(rs("Title_Id").value) Then Title_Id = rs("Title_Id").value
            End If
            rs.close()
            If Title_Id <> 0 Then
                rs.open("select *  from Goods_Title_Program where id=" & Title_Id, conn, 1, 3)
                If Not rs.eof Then
                    If Not IsDBNull(rs("moban").value) Then GoodsTitle = rs("moban").value
                End If
                rs.close()
            End If

        End If
        If GoodsTitle <> "" Then
            GoodsTitle = Replace(GoodsTitle, "<#goods_title>", GetGoodsName)
            GoodsTitle = Replace(GoodsTitle, "<#goods_price>", GetGoodsPrice)
            GoodsTitle = Replace(GoodsTitle, "<#seller_name>", GetGoodsSaller)
            GoodsTitle = Replace(GoodsTitle, "<#seller_credit>", Pic2Seller_Credit)
            GoodsTitle = Replace(GoodsTitle, "<#CurCat_Name>", CurCat_Name)
            GoodsTitle = Replace(GoodsTitle, "<#CurCat_RootCatName>", CurCat_RootCatName)
            GoodsTitle = Replace(GoodsTitle, "<#goods_title_length>", Len(GetGoodsName))
        Else
            GoodsTitle = GetGoodsName()
        End If
        'Response.Write(ShopExlevelPic)
        'Response.End()

    End Sub
End Class
